package com.bcx.controller;

import com.bcx.pojo.Houseinfo;
import com.bcx.service.HouseinfoService;
import com.bcx.tool.ResultEntity;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
@Api(tags = "处理请求")
public class HouseinfoController {
    @Resource
    HouseinfoService houseinfoService;
    @GetMapping("/selectAllHouse")
    @ApiOperation("查询所有house")
    public PageInfo<Houseinfo> selectAll(@RequestParam(required = false,defaultValue = "1") Integer pageNum){
        PageInfo<Houseinfo> pageInfo= houseinfoService.selectAll(pageNum);
          /*  System.out.println("size:"+pageInfo.getList().size());*/
        return pageInfo;
    }
    @GetMapping("/addhouse")
    @ApiOperation("增加house")
    public ResultEntity<String> addhouse(Houseinfo houseinfo){
        Integer integer=houseinfoService.add(houseinfo);
        return ResultEntity.successWithoutData(integer+"");
    }
}
